<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>Dynamic Table</title>

    <!--dynamic table-->
    <link href="/public/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/public/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/js/data-tables/DT_bootstrap.css" />
    <?php $this->load->view('library/header');?>
    <style>
        .popover {max-width: 380px;}
        .cum-nav{
            margin: 15px 0;
            padding: 0;
            list-style: none;
        }
        .cum-nav li {
            display: inline-block;
            background-color: #fff;
            padding: 8px 10px;

        }
        .cum-nav li a {
            font-size: 16px;
            color: #646464;
        }
        .cum-nav li.active {
            background-color: #65CEA7;
        }
        .cum-nav li.active a{
            color: #fff;
        }
        .sku {
            margin-top: 10px;
        }
    </style>
</head>

<body class="sticky-header">

<section>

    <?php $this->load->view('library/left');?>

    <!-- main content start-->
    <div class="main-content" >

        <?php $this->load->view('library/top');?>

        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">

                    <section >
                        <ul class="cum-nav">
                            <li ><a href="<?php echo base_url('Custom/');?>">打板列表</a></li>
                            <li ><a class="nav-link show" href="<?php echo base_url('Custom/index/step/2');?>" >样品列表</a></li>
                            <li class="active"><a class="nav-link show" href="javascript:;" >采购列表</a></li>
                            <li ><a class="nav-link" href="<?php echo base_url('Custom/index/step/4');?>">跟单列表</a></li>
                        </ul>
                    </section>

                    <?php $this->load->view('library/cum_search');?>

                    <section class="panel">
                        <div class="panel-body">
                            <div class="adv-table">
                                <table  class="display table table-bordered table-striped" id="dynamic-table">
                                    <thead>
                                    <tr>
                                        <th width="4%">编号</th>
                                        <th width="4%">图片</th>
                                        <th width="15%">货号</th>
                                        <th width="15%">供应商</th>
                                        <th width="6%">发起时间</th>
                                        <th width="10%">交期时间</th>
                                        <th width="8%" class="hidden-phone">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach ($custom_list as $item): ?>
                                        <tr>
                                            <td><?php echo $item['custom_id'];?></td>
                                            <td><img width="50" src="<?php echo $item['original_img'];?>"></td>
                                            <td>
                                                <?php echo $item['goods_sn'];?>
                                                <br>
                                                <div class="sku">
                                                    <?php if ($item['sku']) : foreach ($item['sku'] as $sku): ?>
                                                        <span class="btn btn-success btn-xs" ><?php echo "{$sku['color']} / {$sku['size']}";?></span>
                                                    <?php endforeach; endif;?>
                                                </div>
                                            </td>
                                            <td>
                                                <b><?php echo $item['suppliers_name'];?></b><a role="button" style="margin-left: 5px;" class="badge badge-info">合格样品</a>
                                            </td>
                                            <td><?php echo date('Y-m-d', $item['add_time']);?></td>
                                            <td>
                                                预期：<?php echo date('Y-m-d', $item['sample_delivery_time']);?>
                                                <br />
                                                实际：<?php echo date('Y-m-d', $item['sample_actual_delivery_time']);?>
                                            </td>
                                            <td>
                                                <a href="<?php echo base_url("Custom/add/custom_id/{$item['custom_id']}/step/5");?>" class="btn btn-xs btn-info" >采购大货</a>
                                            </td>
                                        </tr>
                                    <?php endforeach;?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="row-fluid">
                                <div class="span6">
                                    <div class="dataTables_paginate paging_bootstrap pagination">
                                        <ul>
                                            <?php echo $pages;?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by
        </footer>
        <!--footer section end-->


    </div>
    <!-- main content end-->
</section>
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                <h4 class="modal-title">Form Tittle</h4>
            </div>
            <div class="modal-body">

                <form role="form">
                    <div class="form-group">
                        <label for="exampleInputEmail1">单号</label>
                        <input type="text" class="form-control" id="exampleInputEmail3" placeholder="填写单号">
                    </div>
                    <button type="submit" class="btn btn-primary">Submit</button>
                </form>
            </div>
        </div>
    </div>
</div>
<?php $this->load->view('library/footer');?>

<!--dynamic table-->
<!--<script type="text/javascript" language="javascript" src="/public/js/advanced-datatable/js/jquery.dataTables.js"></script>-->
<!--<script type="text/javascript" src="/public/js/data-tables/DT_bootstrap.js"></script>-->
<!--dynamic table initialization -->
<!--<script src="/public/js/dynamic_table_init.js"></script>-->

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>
<script type="text/javascript">

    $(function () {
        $('.badge').popover({
            'html': true,
            'content': function () {
                return '<h6>样品图</h6><p><img style="max-width: 350px; margin-bottom: 5px;" src="/public/images/gallery/image1.jpg" /><img style="max-width: 350px; margin-bottom: 5px;" src="/public/images/gallery/image2.jpg" /><img style="max-width: 350px; margin-bottom: 5px;" src="/public/images/gallery/image3.jpg" /></p><h6>原因</h6><p>22222</p>';
            }
        });

        $('.a-ajax').on('click', function () {

            var goods_sn = $(this).attr('data-sn');
            var url = $(this).attr('href');

            swal({
                title: goods_sn,
                input: 'text',
                showCancelButton: true,
                allowOutsideClick: false,
                confirmButtonText: 'Submit',
                inputPlaceholder: '请填写运单号',
                inputValidator: function(value) {
                    if (!value) {
                        return '未填写任何运单号!';
                    }
                },
                preConfirm: function preConfirm(value) {
                    swal({
                        imageUrl: '/public/images/Forrest.gif',
                        title: '稍等...',
                        allowOutsideClick: false,
                        showConfirmButton: false
                    });
                    return $.post(url, {pattern_on: value}, function (data) {
                        return data;
                    },'json');
                }
            }).then(function (result) {
                if (result.value) {
                    var data = result.value;
                    swal({
                        type: data.status,
                        title: data.info
                    }).then(function(isConfirm) {
                        location.reload();
                    });
                }
            });

            return false;
        });
    });
</script>
</body>
</html>
